home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / DANG_SRC.LZH / RUN_ME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-06  |  5.9 KB  |  213 lines

  1. #include <gemdefs.h>
  2. #include <osbind.h>
  3. #include <stdio.h>
  4.  char pix1[]  ="START0.DAT";
  5.  char pix2[]  ="START1.DAT";
  6.  char pix3[]  ="START2.DAT";
  7.  
  8.  
  9. int savepal[16],pal1[16],pal2[16],pal3[16],junkbuff[46];
  10. char     temp_[32000],                     /* Temp buffer where file is read in    */
  11.          *hld,
  12.          *iff_in, *iff_out;                  /* Pointers for DEGAS unpack() routine    */
  13.  
  14. main()
  15. {
  16. char *scr1,*scr2,*scr3,command[20];
  17.  
  18.  
  19.  
  20.  
  21.    scr1 = malloc(32768+256);  /*allocate memory for 2nd screen */
  22.     if ((long) scr1 & 0xff)
  23.       scr1 = scr1 + (0x100 - (long)scr1 & 0xff);
  24.       
  25.     scr2 = malloc(32768+256);  /*allocate memory for 2nd screen */
  26.     if ((long) scr2 & 0xff)
  27.       scr2 = scr2 + (0x100 - (long)scr2 & 0xff);
  28.   
  29.     scr3 = malloc(32768+256);  /*allocate memory for 2nd screen */
  30.     if ((long) scr3 & 0xff)
  31.       scr3 = scr3 + (0x100 - (long)scr3 & 0xff);
  32.  
  33.  
  34.  /* read back screen into memory */
  35.  read_stuff(pix2,scr2,pal2);
  36.  read_stuff(pix3,scr3,pal3);
  37.  
  38.  
  39. /* find screen base */
  40. scr1 = (char *)Physbase(); 
  41. read_stuff(pix1,scr1,pal1);  /* read main title screen onto the screen*/
  42. Setpalette(pal1);        /* tel sys to use these colors! */
  43.  
  44. command[0] = strlen("intro 11000 -q -l");
  45. strcpy(&command[1],"intro 11000 -q -l");
  46. Pexec(0,"MUSIC",command,command);          /* loop until keypress */
  47.  
  48. Setpalette(pal2);
  49. Setscreen(scr2,scr2,-1);
  50. delay_();
  51. Setpalette(pal3);
  52. Setscreen(scr3,scr3,-1);
  53. delay_();
  54. free(scr1);
  55. free(scr2);
  56. free(scr3);
  57. Pexec(0,"select","","");
  58.  
  59.  
  60. }
  61.  
  62. /******/
  63. delay_()
  64.  
  65. {
  66.  char com;
  67.  
  68.  com = Bconin( 2 );
  69.  
  70.  
  71. }
  72.  
  73.  
  74. /************************/
  75. read_stuff(hold,adrr,pal)
  76. char hold[];
  77. register char *adrr;
  78. int pal[];
  79.  
  80. {
  81.  char buf[130];
  82.  int lines,i,filehandle;
  83.  
  84. filehandle = Fopen(hold,0); 
  85.  
  86. for(i=0; i<16;i++)
  87.  savepal[i]=Setcolor(i,-1);
  88. /* read header data */
  89. i=Fread(filehandle,2L,buf);
  90.  
  91.  
  92. /* read 16 words of palette data into newpal array */
  93. i =Fread(filehandle,32L,pal);
  94.  
  95.  
  96.  
  97.  
  98. i=Fread(filehandle,32000L,temp_);  /* read image onto back screen*/
  99. /* Close file */
  100. Fclose(filehandle);
  101.      lines = 200;                     /* Low, med-res    */
  102.                  iff_in  = temp_;                /* iff_in pts to temp_buf*/
  103.                  iff_out = adrr;      /* iff_out pts to pic_buffer*/
  104.                   do        
  105.          unpack(0);                                      /* Unpack a line at a time */
  106.                   while (--lines); 
  107.  
  108.        
  109. }
  110. /************************/
  111.  
  112. /***********************/
  113.  
  114. /*---------------------------------------------------------------------------*/
  115. /*                             |--------- DEGAS ---------|            */
  116. /*                              UNCOMPRESSED   COMPRESSED            */
  117. /*                 NEO  low med mono   low med mono     TINY    */
  118. /*    typ...        0     1   2   3     4   5   6     7        */
  119.  
  120. /* Unpacks a single scan line & updates iff_in & iff_out global pointers
  121.  
  122.                      /    byt ==  0 to  127  copy next [byt+1] bytes
  123. Unpack routine --if-<    byt == -1 to -127  copy next byte [-byt+1] times
  124.                      \    byt == 128         NO-OP                            */
  125.  
  126. unpack(rez)
  127. int     rez;
  128.  
  129. {
  130.     register char     *src_ptr, *dst_ptr,           /* ptrs to source/dest */
  131.               byt, cnt;                     /* byt holds the ACTUAL compressed data code(control byte ) */
  132.     register int      minus128 = -128, 
  133.               len;                          
  134.     char                 linbuf[320];                            /* Oversize just in case! */
  135.     int                      llen;
  136.  
  137.  
  138.     if (rez < 2)     len = 160;
  139.     else             len = 80;
  140.     llen = len;
  141.     src_ptr = iff_in;           /* iff_in is ptr to compressed data */
  142.     dst_ptr = &linbuf[0];       /* linbuf WILL hold an ENTIRE Uncompressed scan line. 4 bitplanes * 80 = 320 max! */ 
  143.  
  144.     while (len > 0)
  145.    {
  146.             byt = *src_ptr++;       /* get byte value at address scr_ptr, THEN inc scr_ptr+1 */
  147.             if (byt >= 0)           /* If ctrl code >= 0 then use the next x+1 bytes*/
  148.     {
  149.                  ++byt;                 /* inc byt +1 */
  150.                   do 
  151.        {
  152.                         *dst_ptr++ = *src_ptr++;  /* get byte value from address source, and inc the 2 ptrs */
  153.                         --len;                    /* one byte down.. */
  154.                    }
  155.          while (--byt);           /* do this byt TIMES (remember byt here = byt+1 */
  156.              }
  157.              else 
  158.        if (byt != minus128)       /* else if ctrl code NOT = -128*/
  159.          {                        /*Then use the next byte -x+1 times, (-x) cause x will be negative and - - = + */
  160.                       cnt = -byt + 1;         /* cnt = -x + 1 */
  161.                       byt = *src_ptr++;       /* byt = THE very next byte past the ctrl code(or ctrl byte! */
  162.                        do {
  163.                                *dst_ptr++ = byt;  /* store that byte */
  164.                                --len;         
  165.                           }
  166.                while (--cnt);    /* keep doing it cnt times */
  167.                   }
  168.         }
  169.  
  170.     ilbm_st(linbuf, iff_out, rez);   /* convert the format line */
  171.     iff_in = src_ptr;                                    /* Update global pointers */
  172.     iff_out += llen;
  173.  
  174. }                                /* end of module uncompress() */
  175.  
  176. /*---------------------------------------------------------------------------*/
  177.  
  178. ilbm_st(src_ptr, dst_ptr, rez)           /* Convert ILBM format line to ST format */
  179. int         *src_ptr, *dst_ptr, rez;
  180. {
  181.     int         x, *p0_ptr, *p1_ptr, *p2_ptr, *p3_ptr;
  182.  
  183.     if (rez==0) 
  184.  {                                                     /* Low-res */
  185.         p0_ptr = src_ptr;
  186.         p1_ptr = src_ptr + 20;
  187.         p2_ptr = src_ptr + 40;
  188.         p3_ptr = src_ptr + 60;
  189.         for (x=0; x<20; ++x)
  190.   {
  191.                *dst_ptr++ = *p0_ptr++;
  192.                *dst_ptr++ = *p1_ptr++;
  193.                *dst_ptr++ = *p2_ptr++;
  194.                *dst_ptr++ = *p3_ptr++;
  195.           }
  196.     } 
  197.  else if (rez==1) 
  198.   {                                            /* Med-res */
  199.            p0_ptr = src_ptr;
  200.            p1_ptr = src_ptr + 40;
  201.            for (x=0; x<40; ++x)
  202.     {
  203.                  *dst_ptr++ = *p0_ptr++;
  204.                  *dst_ptr++ = *p1_ptr++;
  205.             }
  206.     }
  207.     else 
  208.      {                                                   /* Monochrome */
  209.               for (x=0; x<40; ++x)
  210.                   *dst_ptr++ = *src_ptr++;
  211.          }
  212.  }
  213.